package com.java.crazy.part5.practice;

import com.java.crazy.base.BaseClass;
import com.java.crazy.part5.practice.bean.StudentBean;

/**
 * 练习练习练习练习练习练习练习练习练习练习练习练习练习练习练习练习
 *
 * @author lblblblblblblblblblblblblblb
 * @since 2018/5/12
 */
public class Practice extends BaseClass {
    private static String TAG = "Practice 5";
    static StudentBean[] studentBeans;

    static {
        studentBeans = new StudentBean[5];
        for (int i = 0; i < studentBeans.length; i++) {
            studentBeans[i] = new StudentBean("name" + i, "gender" + i, "address" + i, "email" + i, 14 + i, "110" + i);
        }
    }

    public static void main(String[] args) {
        findStudent("name2", "email1", "address1");
    }

    /**
     * 查询学生
     * <pre>{@code
     *        演示如何使用该方法
     *       List<Goods> items = new ArrayList<>();
     *        Goods goods = new Goods(1L, BigDecimal.ONE);
     *        Goods goods2 = new Goods(2L, BigDecimal.TEN);
     *        items.add(goods);
     *        items.add(goods2);
     *
     *        Order order1 = new Order();
     *        order.setUserId("1");
     *        order.setItems(items);
     *        OrderService#createOrder(order);
     *       }
     * </pre>
     *
     * @param name    名字
     * @param email   邮箱
     * @param address 地址
     */
    public static void findStudent(String name, String email, String address) {
        for (StudentBean studentBean : studentBeans) {
            if (studentBean.getName().equals(name) && studentBean.getEmail().equals(email) && studentBean.getAddress().equals(address)) {
                logi(TAG, "success=" + studentBean.toString());
                return;
            }
        }
        logi(TAG, "error!!!");

    }
}
